package com.huatai.dataservice.fire.firemodel;

import java.util.Arrays;

/**
 * @author gaowengui
 * 救援类型
 */
public enum RescueTypeEnum {
	FIRE_FIGHTING("火灾扑救"),
	SOCIAL_ASSISTANCE("社会救助"),
	EMERGENCY_RESCUE("抢险救援"),
	OTHER_MOBILIZATION("其他出动");
	private final String displayName;

	RescueTypeEnum(String displayName) {
		this.displayName = displayName;
	}
	// 1. 修复类型匹配逻辑（通过displayName匹配）
	public static RescueTypeEnum fromDisplayName(String displayName) {
		return Arrays.stream(values())
			.filter(type -> type.getDisplayName().equals(displayName))
			.findFirst()
			.orElseThrow(() -> new IllegalArgumentException(
				"无效的救援类型名称: " + displayName +
					"，有效类型：" + Arrays.toString(values())
			));
	}

	public static RescueTypeEnum getPeriod(String type) {
		for (RescueTypeEnum rescueType : values()) {
			if (type.equals(RescueTypeEnum.EMERGENCY_RESCUE)){
				return rescueType;
			}else if (RescueTypeEnum.FIRE_FIGHTING.equals(rescueType)){
				return rescueType;
			} else if (RescueTypeEnum.SOCIAL_ASSISTANCE.equals(rescueType)) {
				return rescueType;
			} else if (RescueTypeEnum.OTHER_MOBILIZATION.equals(rescueType)) {
				return rescueType;
			}
		}
		throw new IllegalArgumentException("无效: " + type);
	}

	public String getDisplayName() {
		return displayName;
	}
}
